import { UserDto } from 'src/core/dto/user.dto';
import { UsersService } from './../../core/service/users.service';
import { Injectable } from "@nestjs/common";


@Injectable()
export class OrderService {
    //注入core模块里的service
    constructor(private readonly u: UsersService) { }

    async createOrder(userId: string) {
        // 使用共享的 UserService 获取用户信息
        const user: UserDto = await this.u.getUser(userId);
        if (!user) {
            return { message: ' 用户不存在 ' };
        }
        return {
            orderId: 'ORD' + Date.now(),
            userId: user.id, username: user.username,
            // 从共享服务获取的用户名
            createTime: new Date().toString,
            status: ' 已创建 '
        }
    }
}